package org.jeecg.modules.basic.demo.apartment.entity;

import lombok.Data;
import org.jeecg.modules.basic.demo.school.entity.SchoolTreeModel;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
public class LwgyBaseApartmentTreeList implements Serializable {
    private static final long serialVersionUID = 1L;

    /** 对应school中的id字段,前端数据树中的key*/
    private String key;

    /** 对应school中的id字段,前端数据树中的value*/
    private String value;

    /** 对应school_name字段,前端数据树中的title*/
    private String title;


    private boolean isLeaf;
    // 以下所有字段均与SysDepart相同
    private String id;
    private String name;
    private String create_by;
    private Date create_time;
    private String update_by;
    private Date update_time;
    private String sys_org_code;
    private String pid;
    private String has_child;
    private String code;
    private String type;
    private Integer level;
    private String room_orientation;
    private String admin;
    private String room_sex;
    private String inner_code;

    private List<LwgyBaseApartmentTreeList> children = new ArrayList<>();

    public LwgyBaseApartmentTreeList() {}

    public boolean isLeaf() {
        return isLeaf;
    }

    public void setLeaf(boolean leaf) {
        isLeaf = leaf;
    }

    public LwgyBaseApartmentTreeList(LwgyBaseApartment lwgyBaseApartment) {
        this.key = lwgyBaseApartment.getId();
        this.value = lwgyBaseApartment.getId();
        this.title = lwgyBaseApartment.getName();
        this.id = lwgyBaseApartment.getId();
        this.name = lwgyBaseApartment.getName();
        this.create_by = lwgyBaseApartment.getUpdateBy();
        this.create_time = lwgyBaseApartment.getCreateTime();
        this.update_by = lwgyBaseApartment.getUpdateBy();
        this.update_time = lwgyBaseApartment.getUpdateTime();
        this.sys_org_code = lwgyBaseApartment.getSysOrgCode();
        this.pid = lwgyBaseApartment.getPid();
        this.has_child = lwgyBaseApartment.getHasChild();
        this.code = lwgyBaseApartment.getCode();
        this.type = lwgyBaseApartment.getType();
        this.level = lwgyBaseApartment.getLevel();
        this.room_orientation = lwgyBaseApartment.getRoomOrientation();
        this.admin = lwgyBaseApartment.getAdmin();
        this.room_sex = lwgyBaseApartment.getRoomSex();
        this.inner_code = lwgyBaseApartment.getInnerCode();
    }
    public void setChildren(List<LwgyBaseApartmentTreeList> children) {
        if (children==null){
            this.isLeaf=true;
        }
        this.children = children;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LwgyBaseApartmentTreeList that = (LwgyBaseApartmentTreeList) o;
        return id.equals(that.id) &&
                name.equals(that.name) &&
                create_by.equals(that.create_by) &&
                create_time.equals(that.create_time) &&
                update_by.equals(that.update_by) &&
                update_time.equals(that.update_time) &&
                sys_org_code.equals(that.sys_org_code) &&
                pid.equals(that.pid) &&
                has_child.equals(that.has_child) &&
                code.equals(that.code) &&
                type.equals(that.type) &&
                level.equals(that.level) &&
                room_orientation.equals(that.room_orientation) &&
                admin.equals(that.admin) &&
                room_sex.equals(that.room_sex) &&
                inner_code.equals(that.inner_code) &&
                children.equals(that.children);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, create_by, create_time, update_by, update_time, sys_org_code, pid, has_child, code, type, level, room_orientation, admin, room_sex, inner_code, children);
    }
}
